home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / include / user / RCS / net.h,v < prev    next >
Encoding:
Text File  |  1992-07-17  |  7.7 KB  |  293 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  srv030:1.2 srv027:1.2 srv026:1.2 srv024:1.2 srv021:1.2 srv019:1.2 srv018:1.2 srv016:1.2 srv014:1.2 srv010:1.2 srv008:1.2 srv007:1.2 srv006:1.2 srv005:1.2 srv004:1.2 srv003:1.2 srv002:1.2 srv001:1.2;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     91.11.11.23.08.48;  author kupfer;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     91.10.21.22.08.40;  author kupfer;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @Changes for sprited.
  27. @
  28. text
  29. @/*
  30.  * net.h --
  31.  *
  32.  *    Declarations of the network library code.
  33.  *
  34.  * Copyright 1987 Regents of the University of California
  35.  * Permission to use, copy, modify, and distribute this
  36.  * software and its documentation for any purpose and without
  37.  * fee is hereby granted, provided that the above copyright
  38.  * notice appear in all copies.  The University of California
  39.  * makes no representations about the suitability of this
  40.  * software for any purpose.  It is provided "as is" without
  41.  * express or implied warranty.
  42.  *
  43.  * $Header: /r3/kupfer/spriteserver/include/user/RCS/net.h,v 1.1 91/10/21 22:08:40 kupfer Exp Locker: kupfer $ SPRITE (Berkeley)
  44.  */
  45.  
  46. #ifndef _NET_USER
  47. #define _NET_USER
  48.  
  49. #include <sprite.h>
  50. #include <machparam.h>
  51. #include <netEther.h>
  52. #include <netInet.h>
  53. #include <netUltra.h>
  54.  
  55. /*
  56.  * A network address.  The "generic" field must be at least as large as
  57.  * any of the other fields and must be an integral number of integers.
  58.  */
  59. typedef union Net_Address {
  60.     Net_EtherAddress        ether;
  61.     Net_InetAddress        inet;
  62.     Net_UltraAddress        ultra;
  63.     struct { char data[8]; }     generic;
  64. } Net_Address;
  65.  
  66. /*
  67.  * Macro to compare two Net_Address objects.
  68.  */
  69. #define NET_ADDRESS_COMPARE(a,b) \
  70.     (bcmp((char *) &(a), (char *) &(b), sizeof(Net_Address)))
  71.  
  72. /*
  73.  * Maximum number of network protocols.  Right now we support two,
  74.  * raw (ethernet for example) and inet
  75.  */
  76.  
  77. #define NET_MAX_PROTOCOLS 2
  78.  
  79. /*
  80.  * The different protocols.
  81.  */
  82.  
  83. #define NET_PROTO_RAW    0
  84. #define NET_PROTO_INET    1
  85.  
  86.  
  87. /* 
  88.  * This is the version number stored in the route.  Set this before
  89.  * installing a route and check it when looking at one.
  90.  */
  91. #define NET_ROUTE_VERSION 0x70500
  92.  
  93. /*
  94.  * Number of different types of networks. 
  95.  */
  96.  
  97. #define NET_NUM_NETWORK_TYPES 2
  98.  
  99. /*
  100.  * Type of network.  See below.
  101.  */
  102.  
  103. typedef int Net_NetworkType;
  104.  
  105. /*
  106.  * Types of network (values for Net_NetworkType).
  107.  */
  108.  
  109. #define NET_NETWORK_ETHER    ((Net_NetworkType) 0)    /* Ethernet. */
  110. #define NET_NETWORK_ULTRA    ((Net_NetworkType) 1)    /* Ultranet. */
  111.  
  112. /*
  113.  * This structure defines the packet headers.
  114.  */
  115. typedef union Net_Header {
  116.     Net_EtherHdr    etherHdr;    /* Raw ethernet packet. */
  117.     struct {                /* An IP packet on the ethernet. */
  118.     Net_EtherHdr    etherHdr;
  119.     Net_IPHeader    ipHdr;
  120.     } inetHdr;        
  121. } Net_Header;
  122.  
  123. /*
  124.  * The user-level view of a route. This structure is used to both install
  125.  * routes and to get their contents.  The fields are marked 'in' if they
  126.  * must be set to install a route, and 'out' if they are set when 
  127.  * getting a route's contents.
  128.  */
  129.  
  130. typedef struct Net_RouteInfo {
  131.     int            version;    /* Version number. (in/out)*/
  132.     int            spriteID;    /* Sprite ID of route target. (in/out)*/
  133.     int            interface;    /* The interface number to use. 
  134.                      * (in/out) */
  135.     int            protocol;    /* Route protocol. (in/out) */
  136.     int            flags;        /* Flags. See below. (in/out) */
  137.     int            refCount;    /* Number of references to route. 
  138.                      * (out). */
  139.     int            routeID;    /* Unique route ID. (in/out)*/
  140.     int            maxBytes;    /* Maximum transfer unit for route. 
  141.                      * This does not include any headers.
  142.                      * (out) */
  143.     int            minBytes;    /* Minimum transfer unit for route. 
  144.                      * This does not include any headers.
  145.                      * (out) */
  146.     Net_NetworkType    netType;    /* Type of network. See above. (out) */
  147.     Net_Address        netAddress[NET_MAX_PROTOCOLS];    /* Address of target
  148.                              * for each protocol.
  149.                                (in/out) */
  150.     char        desc[64];    /* Route description for debugging.
  151.                      * (out) */
  152.     char        hostname[20];    /* Host name. (in/out) */
  153.     char        machType[12];    /* Host machine type. (in/out) */
  154.     ClientData        userData;    /* Data that is uninterpreted by 
  155.                      * kernel. (in/out) */
  156.     Net_Header        header;        /* The packet header. (out) */
  157. } Net_RouteInfo;
  158.  
  159.  
  160. /*
  161.  * Define the flags field.
  162.  */
  163.  
  164. #define NET_FLAGS_VALID 0x1
  165.  
  166. /*
  167.  * Define the special Sprite ID used for broadcasting.
  168.  */
  169. #define        NET_BROADCAST_HOSTID    0
  170.  
  171.  
  172. /* 
  173.  * If we're building a kernel or server, don't include this declaration.  It 
  174.  * clashes with the declaration for the internal routine.
  175.  */
  176.  
  177. #if !defined(KERNEL) && !defined(SPRITED)
  178.  
  179. extern ReturnStatus Net_InstallRoute _ARGS_((int spriteID, int flags,
  180.                          int type, ClientData clientData,
  181.                          char *hostname, char
  182.                          *machType));
  183. #endif /* !KERNEL && !SPRITED */
  184.  
  185. /* 
  186.  * The structures defined below here are obsolete and should not be used
  187.  * in new programs.
  188.  */
  189.  
  190. /*
  191.  * A Generic network address...
  192.  */
  193. typedef struct {
  194.     char    data[14];
  195. } Net_GenericAddress;
  196.  
  197. /*
  198.  * Definition of user visible Route structure that is returned
  199.  * via the Test_Stats system call with the NET_GET_ROUTE command.
  200.  */
  201. typedef struct Net_SpriteRoute {
  202.     int        flags;        /* Flags defined in kernel/net.h */
  203.     int        spriteID;    /* Universal Sprite Host ID */
  204.     int        type;        /* Types defined in kernel/net.h */
  205.     union {
  206.     Net_EtherHdr    etherHdr;    /* type == NET_ROUTE_ETHER */
  207.     char        data[14];    /* type == NET_ROUTE_GENERIC */
  208.     struct {
  209.         Net_EtherHdr    etherHdr;
  210.         Net_IPHeader    ipHdr;
  211.     } inetHdr;            /* type == NET_ROUTE_INET */
  212.     } route;
  213. } Net_SpriteRoute;
  214.  
  215.  
  216. /*
  217.  * Declarations for -lnet library.
  218.  */
  219.  
  220. extern Net_InetAddress    Net_StringToInetAddr _ARGS_((char *cp));
  221. extern ReturnStatus    Net_StringToAddr _ARGS_((char *buffer, int protocol,
  222.                          Net_NetworkType netType,
  223.                          Net_Address *addressPtr));
  224. extern char        *Net_InetAddrToString _ARGS_((Net_InetAddress address,
  225.                               char *buffer));
  226. extern char        *Net_AddrToString _ARGS_((Net_Address *netAddressPtr,
  227.                           int protocol,
  228.                           Net_NetworkType netType,
  229.                           char *buffer));
  230. extern unsigned int    Net_StringToNetNum _ARGS_((char *cp));
  231. extern unsigned int    Net_InetAddrHostNum _ARGS_((Net_InetAddress inetAddr));
  232. extern unsigned int    Net_InetAddrNetNum _ARGS_((Net_InetAddress addr));
  233. extern unsigned int    Net_InetAddrNetMask _ARGS_((Net_InetAddress addr));
  234. extern Net_InetAddress    Net_MakeInetAddr _ARGS_((unsigned int net,
  235.                          unsigned int host));
  236. extern char    *Net_EtherAddrToString _ARGS_((Net_EtherAddress *etherAddrPtr,
  237.                            char buffer[18]));
  238. extern void    Net_StringToEtherAddr _ARGS_((char *buffer,
  239.                        Net_EtherAddress *etherAddressPtr));
  240. extern unsigned short    Net_InetChecksum _ARGS_((int len, Address bufPtr));
  241. extern unsigned short    Net_InetChecksum2 _ARGS_((int len, Address bufPtr,
  242.                            Net_IPPseudoHdr *pseudoHdrPtr));
  243.  
  244. #if BYTE_ORDER == LITTLE_ENDIAN
  245. extern unsigned int    Net_NetToHostInt _ARGS_((unsigned int longInt));
  246. extern unsigned int    Net_HostToNetInt _ARGS_((unsigned int longInt));
  247.  
  248. extern unsigned short    Net_NetToHostShort _ARGS_((unsigned short shortInt));
  249. extern unsigned short    Net_HostToNetShort _ARGS_((unsigned short shortInt));
  250. #else 
  251. #define Net_NetToHostInt(arg)    (arg)
  252. #define Net_HostToNetInt(arg)    (arg)
  253.  
  254. #define Net_NetToHostShort(arg)    (arg)
  255. #define Net_HostToNetShort(arg)    (arg)
  256. #endif
  257.  
  258.  
  259. #endif _NET_USER
  260. @
  261.  
  262.  
  263. 1.1
  264. log
  265. @Initial revision
  266. @
  267. text
  268. @d15 1
  269. a15 1
  270.  * $Header: /sprite/src/lib/include/RCS/net.h,v 1.10 90/10/19 15:50:56 jhh Exp $ SPRITE (Berkeley)
  271. d21 5
  272. a25 5
  273. #include "machparam.h"
  274. #include "netEther.h"
  275. #include "netInet.h"
  276. #include "netUltra.h"
  277. #include "sprite.h"
  278. d29 1
  279. a29 1
  280.  * any of the other fields.
  281. d145 2
  282. a146 2
  283.  * If we're building a kernel, don't include this declaration.  It 
  284.  * clashes with the declaration for the real kernel routine.
  285. d149 1
  286. a149 1
  287. #ifndef KERNEL
  288. d155 1
  289. a155 2
  290.  
  291. #endif /* KERNEL */
  292. @
  293.